package cn.t12.quartzspringbootdemo.job;

import cn.t12.quartzspringbootdemo.service.RemindService;
import cn.t12.quartzspringbootdemo.service.ScheduledService;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

public class RemindJob extends QuartzJobBean {
    private static Logger logger = LoggerFactory.getLogger(QuartzJobBean.class);

    private RemindService remindService;

    public RemindJob(RemindService remindService){
        logger.info("创建对象: RemindJob");
        this.remindService = remindService;
    }

    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        logger.info("开始提醒任务222...,当前线程:[{}],当前时间:[{}]",Thread.currentThread().getName(),new Date());
        remindService.remind();
        logger.info("完成提醒任务222...,当前线程:[{}],当前时间:[{}]",Thread.currentThread().getName(),new Date());
    }
}
